package com.ruoyi.merchant.mapper;


import com.ruoyi.common.core.cg.pojo.*;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

/**
* @author ？？？
* @description 针对表【group】的数据库操作Mapper
* @createDate 2025-03-14 15:37:02
* @Entity com.zt.pojo.Group
*/
@Mapper
public interface GroupMapper {

    //根据id查询商品信息
    List<Group> queryGroup(int lid);

    //查询商品信息
    List<Group> groupList();

    //发起拼团信息
    @Insert("insert into `group`(people,\n" +
            "pick_up_time,price,group_price,\n" +
            "status,create_time,limit_buy,\n" +
            "end_time,surface_plot,first_img,\n" +
            "second_img,remark,invitation_code,\n" +
            "name,max_group,group_status)\n" +
            "values(#{people},\n" +
            "#{pickUpTime},#{price},#{groupPrice},\n" +
            "#{status},#{createTime},#{limitBuy},\n" +
            "#{endTime},#{surfacePlot},#{firstImg},\n" +
            "#{secondImg},#{remark},#{invitationCode},\n" +
            "#{name},#{maxGroup},#{groupStatus}\n" +
            ")")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int saveGroup(Group group);

    // 拼团 数据
    Integer findCountByDate(@Param("date") String date);


    /**
     * 根据日期查询销售额
     * @param date 日期，格式为yyyy-MM
     * @return 销售额
     */
    BigDecimal findSalesByDate(@Param("date") String date,@Param("lid") Integer lid);

    /**
     * 根据日期查询客户数量
     * @param date 日期，格式为yyyy-MM
     * @return 客户数量
     */
    Integer findCustomerCountByDate(@Param("date") String date,@Param("lid") Integer lid);
    
    
    //根据lid查询groupid
    @Select("select * from t_leader_group where leader_id = #{lid}")
    LeaderGroup selectGroupId(int lid);
    
    //根据lid查询storeid
    @Select("select * from t_leader_store where leader_id = #{lid}")
    TLeaderStore selectStoreId(int lid);
    
    //添加t_community_group表
    @Insert("insert into t_community_group(community_id,group_id) values(#{communityId},#{groupId})")
    int saveComGroup(TCommunityGroup tCommunityGroup);
    
    //添加t_store_group表
    @Insert("insert into t_store_group(store_id,group_id) values(#{storeId},#{groupId})")
    int saveStoreGroup(StoreGroup storeGroup);


}




